/*
 * utils.h
 *
 *  Created on: 10.06.2012
 *      Author: sebastian
 */

//TODO: ugly.... as it's not oop
//TODO docmentate

#ifndef MMUTILS_H_
#define MMUTILS_H_

#include <string>
#include <sstream>

#define PATHTOSHARE "share/" //TODO: use configfile instead

inline int myAbs(int i) {
	return (i<0 ? -i : i);
}

std::string intToStr(int i);

template<typename T>
std::string toString(T t) {
	std::ostringstream strs;
	strs << t;
	return strs.str();
}

inline std::string boolToStr(bool b) {
	return b ? "true" : "false";
}

/**
 * @param fileName Filename
 * @param cache if this website shall be cached
 * Hint: Cached mode works only in release mode to make html development easier
 * @return "" if file is empty or Error.
 */
std::string fileToStr(const std::string fileName, bool cache = false);

enum LogType {
	LT_NORMAL,
	LT_ERROR
};

void mLog(std::string s, LogType l = LT_NORMAL);

inline void DmLog(std::string s, LogType l = LT_NORMAL) { //low: enhance performance of this
	#ifdef DEBUG
		mLog(s, l);
	#endif
	return;
}

std::string getValue(const std::string &input, const std::string &paramName);
//gets value after ": " or "=" till ; \n ' ' & or file ending


#endif
